﻿<phone:PhoneApplicationPage
    x:Class="LightOMator.View.EditPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"    
    xmlns:cimbalino="clr-namespace:Cimbalino.Phone.Toolkit.Behaviors;assembly=Cimbalino.Phone.Toolkit"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:conding4fun="clr-namespace:Coding4Fun.Toolkit.Controls;assembly=Coding4Fun.Toolkit.Controls"
    xmlns:local="clr-namespace:LightOMator.View"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="True"
    DataContext="{Binding Edit, Source={StaticResource Locator}}"
    >

    <!--LayoutRoot is the root grid where all page content is placed-->
    <ScrollViewer>
        <Grid x:Name="LayoutRoot" Background="Transparent">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <!--TitlePanel contains the name of the application and page title-->
            <StackPanel Grid.Row="0" Margin="12,17,0,28">
                <TextBlock Text="LIGHT-O-MATOR" Style="{StaticResource PhoneTextNormalStyle}"/>
                <TextBlock Text="edit" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
            </StackPanel>

            <!--ContentPanel - place additional content here-->
            <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <TextBlock Text="Name" />
                <TextBox Text="{Binding Fades.Name, Mode=TwoWay}" Grid.Row="1"/>
                <TextBlock Text="Fade mode" Grid.Row="2" Visibility="Collapsed"/>
                <StackPanel Orientation="Vertical" Grid.Row="3" Visibility="Collapsed">
                    <RadioButton Content="direct" GroupName="fademode" IsChecked="{Binding IsFadeModeDirect, Mode=TwoWay}" />
                    <RadioButton Content="black" GroupName="fademode" IsChecked="{Binding IsFadeModeBlack, Mode=TwoWay}" />
                    <RadioButton Content="none" GroupName="fademode" IsChecked="{Binding IsFadeModeNone, Mode=TwoWay}" />
                </StackPanel>
                <ListBox ItemsSource="{Binding Fades.Fades}" ScrollViewer.VerticalScrollBarVisibility="Disabled" Grid.Row="4">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Margin="0,5">
                                <StackPanel.Background>
                                    <SolidColorBrush Color="{Binding Color}"/>
                                </StackPanel.Background>

                                <local:ColorButton MinHeight="80" Color="{Binding Color,Mode=TwoWay}"/>
                                <Grid Background="{StaticResource PhoneChromeBrush}" Margin="5">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="*"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Text="fade in" VerticalAlignment="Center" Margin="5"/>
                                    <local:TimeSpanControl Number="{Binding FadeInTimeMs, Mode=TwoWay}"  Background="{StaticResource PhoneChromeBrush}" Grid.Column="1"/>
                                    <TextBlock Text="keep on" VerticalAlignment="Center" Margin="5" Grid.Row="1" />
                                    <local:TimeSpanControl Number="{Binding KeepOnTimeMs, Mode=TwoWay}"  Background="{StaticResource PhoneChromeBrush}" Grid.Row="1" Grid.Column="1"/>
                                </Grid>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                    <ListBox.ItemContainerStyle>
                        <Style TargetType="ListBoxItem">
                            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                            <Setter Property="VerticalContentAlignment" Value="Center"/>
                            <Setter Property="HorizontalAlignment" Value="Stretch"/>
                            <Setter Property="VerticalAlignment" Value="Top"/>
                        </Style>
                    </ListBox.ItemContainerStyle>
                </ListBox>
                <!-- scroll element so that I can open the last listbox element's timespan picker comfortably -->
                <StackPanel MinHeight="200" Grid.Row="5" />
            </Grid>
        </Grid>
    </ScrollViewer>
    <!-- cimbalino application bar -->
    <i:Interaction.Behaviors>
        <cimbalino:ApplicationBarBehavior>
            <cimbalino:ApplicationBarIconButton Command="{Binding AddColorCommand, Mode=OneTime}" IconUri="/Assets/appbar_plus.png" Text="add color" />
            <cimbalino:ApplicationBarIconButton Command="{Binding RemoveColorCommand, Mode=OneTime}" IconUri="/Assets/appbar_minus.png" Text="remove color" />
            <cimbalino:ApplicationBarIconButton Command="{Binding SaveFadesCommand, Mode=OneTime}" IconUri="/Assets/appbar_save.png" Text="save" />
            <cimbalino:ApplicationBarIconButton Command="{Binding DeleteFadesCommand, Mode=OneTime}" IconUri="/Assets/appbar_delete.png" Text="delete" />
        </cimbalino:ApplicationBarBehavior>
    </i:Interaction.Behaviors>

</phone:PhoneApplicationPage>